<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
//    Object.defineProperty方法直接在一个对象上定义一个新属性,或者修改一个已经存在的属性, 并返回这个对象。
    const obj = {}
    Object.defineProperty(obj,'age',{
        value:13,
        writable:true,
        enumerable:true,
        configurable:true
    })
    obj.age = 20
    console.log(obj)

    Object.defineProperty(obj,'name',{
        get:function proxyGetter(){
            return 'zhangSan'
        },
        set:function proxy(newVal){
            obj.name = newVal
        }
    })
    console.log(obj.name)
</script>
</body>
</html>